/**
 * 
 */
package com.jie.eclipse.pan.gef.action;

import java.net.MalformedURLException;
import java.net.URL;

import org.eclipse.jface.action.Action;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.browser.IWebBrowser;
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;

import com.jie.eclipse.pan.data.BaseDataEntity;
import com.jie.eclipse.pan.editors.utils.PanImageHelper;
import com.jie.eclipse.pan.views.PanDeveloperhelperView;

/**
 * @author yanjie
 *
 */
public class OpenBrowserAction extends Action{
	private PanDeveloperhelperView helperview = null;
	private BaseDataEntity config = null;
	/**
	 * 
	 */
	public OpenBrowserAction(PanDeveloperhelperView helperview,BaseDataEntity config) {
		this.helperview = helperview;
		this.config = config;
		this.setText(this.config.gpsv("text"));
		this.setToolTipText(this.config.gpsv("tiptext",this.config.gpsv("text")));
		this.setImageDescriptor(PanImageHelper.getInstance().getImageDescriptor("icons/gef/eclipse/web-root.gif"));
		//refresh.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
	}
	
	@Override
	public void run() {
		try {
		    IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
		    IWebBrowser browser = support.createBrowser(config.gpsv("id"));
		    browser.openURL(new URL(config.gpsv("url")));
		} catch (PartInitException e) {
		    e.printStackTrace();
		} catch (MalformedURLException e) {
		    e.printStackTrace();
		}
	}
}
